package com.my.myTradeData;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;



public class JavaFile {

	public static List<String> readfile(String path) throws IOException {
		// read file content from file

		List<String> sa = new ArrayList<String>();
		FileReader reader = new FileReader(path);
		BufferedReader br = new BufferedReader(reader);

		String str = null;

		while ((str = br.readLine()) != null) {
			sa.add(str);
		}

		br.close();
		reader.close();
		return sa;
	}

	public static void writefile(String path,String s) throws IOException {
		// read file content from file
		 FileWriter writer = new FileWriter(path);  
         BufferedWriter bw = new BufferedWriter(writer);  
         bw.write(s);  
          
         bw.close();  
         writer.close();  
	}
	
	public static void writefile(String path,String s,boolean append) throws IOException {
		// read file content from file
		 FileWriter writer = new FileWriter(path,append);  
         BufferedWriter bw = new BufferedWriter(writer);  
         bw.write(s);  
          
         bw.close();  
         writer.close();  
	}
	
}